package controllers

import (
	"gitee.com/wao520/obtain_data/pkg/result"
	"gitee.com/wao520/obtain_data/service"
	"github.com/gin-gonic/gin"
)

type GoodsController struct{}

func NewGoodsController() *GoodsController {
	return &GoodsController{}
}

// 购买一件商品,by lock
func (g *GoodsController) LockBuyOne(c *gin.Context) {
	result := result.NewResult(c)

	var goodsId int64 = 3
	buyNum := 2
	err := service.LockBuyOneGoods(goodsId, buyNum)
	if err != nil {
		result.ErrorCode(404, "数据查询错误")
	} else {
		result.Success("减库存成功")
	}
}
